/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package acessoBD;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Caio Valentim
 */
public class AcessoBD {
    Connection con;
        public Connection conectar()
        {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost/cadastro?user=root&password=dharok2");
        } catch (SQLException ex) {
            Logger.getLogger(AcessoBD.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(AcessoBD.class.getName()).log(Level.SEVERE, null, ex);
        }
            return con;
        }
        
        public void desconectar()
        {
            try {            
                con.close();
            } catch (SQLException ex) {
                Logger.getLogger(AcessoBD.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}
